You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(printing): release ShaperFont owners on partial PDF font setup failures - #4528
Two remaining PDF export paths can retain native font references during partial setup failures, despite the main printing flow being fixed in #4302.
Changes
Calendar PDF: use the already-tested withShaperFontPair scope to guarantee the primary owner is released if fallback registration fails and both are released after asynchronous pdf.save() completes, including exceptions.
Tikkun PDF: roll back ShaperFont.register() if _ExportFont/PdfShapedFont construction fails, before the font can enter _fonts and its normal finally cleanup.
No changes to native Rust, ABI, text layout, or successful PDF bytes are intended.
QA / merge gate
Review diff for ownership and save ordering.
Run flutter analyze and existing calendar/Tikkun/PDF tests in GitHub Actions.
Check test failures and CI before merge.
Do not treat CI as an independent human/agent code review.
QA status for head 00fe5dd4c58630433f308a223c7c1d1dd3bc8fa3 (CI run):
flutter analyzepassed.
All five Linux test shards (0–4) passed.
Windows build passed.
Windows tests were blocked while fetching the unrelated sqlite3 native DLL: downloaded SHA256 8e8052a0… did not match the package-expected 3a29878d… (Build assets for package:sqlite3 failed). This occurred before code tests could run.
Linux build failed at Download prebuilt WPE runtime SDK (curl exit code 18), unrelated to the two modified PDF source files.
The changes are confined to font-owner cleanup on partial setup failures. These CI infrastructure issues are not represented as passing checks. Leave this PR open; no merge to Otzaria has been requested.
Ownership regression QA — head 79744a743f13fbda19e5d55a409cde8d71fc5d82
Follow-up implementation/tests were pushed to this PR branch using palmoni5. No merge was performed.
Fault paths exercised
Calendar PDF:withShaperFontPair keeps both font owners alive through the awaited pdf.save(), releases fallback before primary, and releases primary if fallback registration fails. Three successful real Calendar exports verify both distinct native handles have zero residual registry references after cleanup.
Partial registration: a malformed but parseable SFNT registers natively, then fails during Dart ShaperFont construction; the test verifies the fallback's transient native reference is rolled back and the primary is released. The pinned opentype_shaper implementation already contains the rollback from package PR Add PDF search result count #4; a dependency bump was not required.
Tikkun PDF: injectable PDF-font builder and saver retain the original defaults but allow deterministic error injection. Tests verify failure constructing the first and second PdfShapedFont (including a previously cached font), asynchronous save failure after the writer enters save, cancellation after loading/registering a font, and eight repeated successful exports. The existing writer's finally releases cached owners even when save/cancellation throws.
Double-dispose / refcounts: 16 repeated asynchronous failure cycles, including already-disposed owners, confirm idempotent cleanup. Every new lifecycle test checks the native registry using ShaperBindings.releaseFont; unknownHandle after owner disposal confirms no retained registry entry/associated font allocation. This is a native reference-allocation check, not a process-wide RSS/heap measurement.
Successful-output invariants
The default Tikkun factory still constructs PdfShapedFont with the same arguments and extraction callback, and the saver still calls PdfDocument.save(enableEventLoopBalancing: true). Calendar page construction and save are unchanged inside the new resource scope. Existing Calendar and Tikkun vector-PDF/content tests passed. No byte-for-byte golden comparison against the pre-PR artifacts was run, so this is code-path equivalence and output-regression coverage, not a separately measured binary-equivalence claim.
All 5 Linux test shards: success, 25,501 passed / 149 skipped. Logs explicitly report all new Calendar, Tikkun and shaper-scope ownership tests passing.
Windows Tests: success, 3,019 passed / 7 skipped.
Windows Build (including integration and multiview smoke): success.
Linux Build (including engine SQLite integration): success.
Lockfile Guard: success (separately; not used as a substitute for Flutter Tests).
For context, the older run #42477550622 had unrelated infrastructure failures (sqlite3 Windows DLL SHA-256 mismatch and Linux WPE download curl code 18). Both jobs passed in the new run, and those old failures are not classified as application test failures.
A separate source-level second-pass review of the cleanup order and ownership transfer found no missing release path. This review and CI are not presented as an independent external human/agent approval; no such reviewer has signed off on the PR.
Leave PR open; do not merge without explicit authorization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two remaining PDF export paths can retain native font references during partial setup failures, despite the main printing flow being fixed in #4302.
Changes
withShaperFontPairscope to guarantee the primary owner is released if fallback registration fails and both are released after asynchronouspdf.save()completes, including exceptions.ShaperFont.register()if_ExportFont/PdfShapedFontconstruction fails, before the font can enter_fontsand its normal finally cleanup.No changes to native Rust, ABI, text layout, or successful PDF bytes are intended.
QA / merge gate
flutter analyzeand existing calendar/Tikkun/PDF tests in GitHub Actions.Related: Otzaria/opentype_shaper#4, #4302.